﻿@{
    ViewData["Title"] = "首页管理";
    Layout = "~/Views/Shared/_ManageLayout.cshtml";
}
@section css{
    <style>
        .layui-table-cell {
            line-height: 40px;
        }
    </style>
}
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-form toolbar">
                <div class="layui-form-item">
                </div>
            </div>
            <table class="layui-table" lay-even lay-skin="line" lay-size="lg" id="tableTbBas" lay-filter="tableTbBas"></table>
        </div>
    </div>
</div>
<!-- 表格操作列 -->
<script type="text/html" id="tableBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">编辑首页</a>
</script>
<!-- js部分 -->
<script>
    layui.use(['admin', 'layer', 'form', 'table', 'laydate', 'laytpl','upload'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var laydate = layui.laydate;
        var admin = layui.admin;
        var laytpl = layui.laytpl;
        var upload = layui.upload;
        // 渲染表格
        var insTb = table.render({
            elem: '#tableTbBas',
            url: '/api/languageType',
            page: true,
            limit: 30,
            cellMinWidth: 100,
            cols: [[
                { field: 'language', align: 'center', title: '语言版本' },
                { templet: '#tableBar', title: '操作', align: 'center', minWidth: 160 }
            ]]
        });

        //监听工具条
        table.on('tool(tableTbBas)', function (obj) {
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值
            if (layEvent == "edit") {
                var height = $(window).height() * 0.9;
                var width = $(window).width() * 0.9;
                var check = layer.open({
                    type: 2,
                    title: '首页编辑',
                    maxmin: true,
                    shadeClose: true, //点击遮罩关闭层
                    area: [width + 'px', height + 'px'],
                    content: '/manage/WebHomeEdit?languageId=' + data.id,
                });
            }
        });
    });
</script>